<html>

<#include "../header.ftl">

<body>

<form class="layui-form" action="">

  <div class="layui-form-item">
    <label class="layui-form-label">用户名</label>
    <div class="layui-input-inline">
<#--      lay-verify="required" lay-reqtext="用户名是必填项，岂能为空？"    lay-verify="password"-->
      <input type="text" name="name"  placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">密码</label>
    <div class="layui-input-inline">
      <input type="password" name="password"  placeholder="请输入密码" autocomplete="off" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请填写6到12位密码</div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label">创建时间</label>
    <div class="layui-input-inline">
      <input type="text" name="createTime" id="createTime"  autocomplete="off" placeholder="请输入日期" class="layui-input">
    </div>
  </div>


    <div class="layui-input-item">
      <label class="layui-form-label">用户角色</label>
      <div class="layui-input-inline">
        <select name="roleId" id="roleId">
          <option value="3">请选择用户角色</option>
          <option value="4">班主任</option>
          <option value="1">学生</option>
          <option value="2">班长</option>
        </select>
      </div>

    </div>

  <div class="layui-form-item">
    <label class="layui-form-label">是否禁用</label>
    <div class="layui-input-inline">
      <input type="radio" name="salt" value="0" title="禁用">
      <input type="radio" name="salt" value="1" title="不禁用">
    </div>
  </div>


  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
      <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>

<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
  layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

    form.render();
    //日期
    laydate.render({
      elem: '#createTime'
      ,type: 'datetime'
      ,format: 'yyyy年MM月dd日' //可任意组合
      ,isInitValue: true //是否允许填充初始值，默认为 true
      ,value: '2019-12-10'
    });

    //自定义验证规则
    form.verify({
      // name: function(value){
      //   if(value.length < 5){
      //     return '标题至少得5个字符啊';
      //   }
      // }
      // password: [
      //   /^[\S]{6,12}$/
      //   ,'密码必须6到12位，且不能出现空格'
      // ]

    });


    //监听提交
    form.on('submit(demo1)', function(data){
      layer.alert(JSON.stringify(data.field), {
        title: '最终的提交信息'
      })

      layerAjax('add',data.field,'userList')

      //阻止自动跳转
      return false;
    });


  });
</script>

</body>
</html>